
#include <iostream>
#include <string.h>
#include <unistd.h>

using namespace std;

class Human {
private:
	int a;
public:	
	virtual void eating(void) {cout << " use hand to eat " << endl;}
	virtual ~Human() {cout << "~Human()" << endl;}
	virtual Human* test(void) {cout << "Human's test" <<endl; return this; }

};

class Englishman : public Human {
public:
	void eating(void) {cout << " use knife to eat " << endl;}
	virtual ~Englishman() {cout << "~Englishman()" << endl;}
	virtual Englishman* test(void) {
		cout << "Englishman's test" << endl; 
		return this;
	}
};

class Chineseman : public Human {
public:
	void eating(void) {cout << " use chopsticks to eat " << endl;}
	virtual ~Chineseman() {cout << "~Chineseman()" << endl;}
	virtual Chineseman* test(void) {cout << "Chineseman's test" <<endl;return this; }
};

class Guangxiren : public Chineseman{
public:
	void eating(void) {cout << " use chopsticks to eat I'm come from Guangxi" << endl;}
	virtual ~Guangxiren() {cout << "~Guangxiren()" << endl;}
	virtual Guangxiren* test(void) {cout << "Guangxiren's test" <<endl;return this; }


};

void test_eating(Human& h)
{
	//Englishman& pe = dynamic_cast<Englishman&>(h);
	Chineseman& pc = dynamic_cast<Chineseman&>(h);
	Guangxiren& pg = dynamic_cast<Guangxiren&>(h);
	
	h.eating();

	
	
}



int main(int argc , char **argv)
{	
	//Human h;
	//Englishman e;
	//Chineseman c;
	Guangxiren g;

	//test_eating(h);
	//test_eating(e);
	//test_eating(c);
	test_eating(g);
	
	return 0;
}






















